/**********
modules written by lurker

***/
var cmdClear = {
    name:"clear",
    help:"clear screen.",
    run: function( args, callback){
	document.getElementById('screenarea').innerHTML = "";
	callback();
    }
};
Daush.Interpreter.add_module( cmdClear );

var cmdMap = {
    name:'map',
    help:'map [address]<br>display map of given address. powered by <a href="http://sparcs.org/~airlover/9eye.net/map/" target="_blank">NGMap</a>',
    run:function( args, callback ){
	var output = Daush.Interpreter.createOutput();
	var geocoder = new GClientGeocoder();
	var address = args.join(" ");
	console.debug(address);

	var url = 'http://sparcs.org/~airlover/9eye.net/map/NGMap_service.php?view=G&lon=126.94533109399634&lat=37.5266182471996&zoom=12&title=&enc=utf-8'
	geocoder.getLatLng(
	    address,
	    function(point) {
		if (!point) {
		    output.innerHTML = address +" not found";
		    callback(output);
		} else {
		    output.style.height = "300px";
		    output.style.width = "500px";

		    var iframe = document.createElement('iframe');
		    iframe.style.border = 'none';
		    iframe.style.height = '100%';
		    iframe.style.width = '100%';
		    iframe.src = 'http://sparcs.org/~airlover/9eye.net/map/NGMap_service.php?view=G&lon='+point.x+'&lat='+point.y+'&zoom=12&title=&enc=utf-8';
		    output.appendChild(iframe);
		    callback(output);
		}
	    }
	);
    }
};
Daush.Interpreter.add_module( cmdMap);


var cmdGameZoo = {
    name:'game/zookeeper',
    help:'Flash game - ZooKeeper',
    run:function(args, callback ){
	var output = Daush.Interpreter.createOutput();
	output.innerHTML = '<object width="600" height="500" data="http://sinjigun.tistory.com/attachment/jk2.swf" wmode="transparent" type="application/x-shockwave-flash"><p><a href="http://sinjigun.tistory.com/attachment/jk2.swf">[Flash] http://sinjigun.tistory.com/attachment/jk2.swf</a></p></object>';
	output.style.height = "500px";
	output.style.width = "600px";
	callback(output);
    }
};
Daush.Interpreter.add_module( cmdGameZoo);

var cmdGameXeno = {
    name:'game/xeno_tactic',
    help:'Flash game - XenoTactic',
    run:function(args, callback ){
	var output = Daush.Interpreter.createOutput();
	output.innerHTML = '<object width="640" height="480" data="http://blog.tinywolf.com/attachment/hk20.swf" wmode="transparent" type="application/x-shockwave-flash"><p><a href="http://blog.tinywolf.com/attachment/hk20.swf">[Flash] http://blog.tinywolf.com/attachment/hk20.swf</a></p></object>';
	output.style.height = "480px";
	output.style.width = "640px";
	callback(output);
    }
};
Daush.Interpreter.add_module( cmdGameXeno);

var cmdGameMine = {
    name:'game/mine',
    help:'Flash game - Minesweeper',
    run:function(args, callback ){
	var output = Daush.Interpreter.createOutput();
	output.innerHTML = '<object width="550" height="450" data="http://flgame.tistory.com/attachment/dk120000000000.swf" wmode="transparent" type="application/x-shockwave-flash"><p><a href="http://flgame.tistory.com/attachment/dk120000000000.swf">[Flash] http://flgame.tistory.com/attachment/dk120000000000.swf</a></p></object>';
	output.style.height = "450px";
	output.style.width = "550px";
	callback(output);
    }
};
Daush.Interpreter.add_module( cmdGameMine);

var cmdHanmail = {
    name:'mail/naver',
    help:'mail/naver [mailaddress]<br>Compose email using naver',
    run:function(args, callback ){
	var output = Daush.Interpreter.createOutput();
	var email = args[0];
	console.debug(email);
	window.open('http://mail.naver.com/write/?cmd=compose&to='+encodeURI(email));
	callback(output);
    }
};
Daush.Interpreter.add_module( cmdHanmail);



